<?php

header("content-type: text/html; charset=iso-8859-1;", true);

$dbHost = "127.0.0.1:3306";
$dbUser = "root";
$dbPass = "babilonia";
$dbData = "protocolo";

$conn = mysql_connect($dbHost,$dbUser,$dbPass) or die(mysql_error());
mysql_select_db($dbData,$conn) or die(mysql_error());

mysql_query("SET NAMES 'utf8';");

session_start();

$user=$_REQUEST['j_username'];
$password=$_REQUEST['j_password'];

$query="SELECT Setor FROM tab_setor WHERE Setor='$user' AND Senha='$password'";
$sql_select=mysql_query($query) or die (mysql_error());

if(mysql_num_rows($sql_select)) {
	$dados= @mysql_fetch_array($sql_select);
	$_SESSION["Setor"] = stripslashes($dados["Setor"]);
	echo "{success: true}";
}

else {
    echo "{success: false}";
}

?>